/************************************************************************************
 * XmlFileCreator.java
 * Author: Francesco Noya (francesco.noya AT studenti.unimi.it)
 *
 * This activity shows how to write an xml file into the SD card using
 * org.xmlpull.v1.XmlSerializer
 *
 * For more informations check these links:
 *
 * http://developer.android.com/reference/ ... lizer.html
 *
 * http://www.ibm.com/developerworks/opens ... tml#list11
 *
 *
 ************************************************************************************/
 
 
/*  package it.noya.test;
 
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
 
import org.xmlpull.v1.XmlSerializer;
 
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.util.Xml;
import android.widget.TextView;
 
public class XmlFileCreator extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        //create a new file called "new.xml" in the SD card
        File newxmlfile = new File(Environment.getExternalStorageDirectory()+"/new.xml");
        try{
                newxmlfile.createNewFile();
        }catch(IOException e){
                Log.e("IOException", "exception in createNewFile() method");
        }
        //we have to bind the new file with a FileOutputStream
        FileOutputStream fileos = null;        
        try{
                fileos = new FileOutputStream(newxmlfile);
        }catch(FileNotFoundException e){
                Log.e("FileNotFoundException", "can't create FileOutputStream");
        }
        //we create a XmlSerializer in order to write xml data
        XmlSerializer serializer = Xml.newSerializer();
        try {
                //we set the FileOutputStream as output for the serializer, using UTF-8 encoding
                        serializer.setOutput(fileos, "UTF-8");
                        //Write <?xml declaration with encoding (if encoding not null) and standalone flag (if standalone not null)
                        serializer.startDocument(null, Boolean.valueOf(true));
                        //set indentation option
                        serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
                        //start a tag called "root"
                        serializer.startTag(null, "root");
                        //i indent code just to have a view similar to xml-tree
                                serializer.startTag(null, "child1");
                                serializer.endTag(null, "child1");
                               
                                serializer.startTag(null, "child2");
                                //set an attribute called "attribute" with a "value" for <child2>
                                serializer.attribute(null, "attribute", "value");
                                serializer.endTag(null, "child2");
                       
                                serializer.startTag(null, "child3");
                                //write some text inside <child3>
                                serializer.text("some text inside child3");
                                serializer.endTag(null, "child3");
                               
                        serializer.endTag(null, "root");
                        serializer.endDocument();
                        //write xml data into the FileOutputStream
                        serializer.flush();
                        //finally we close the file stream
                        fileos.close();
                       
                TextView tv = (TextView)this.findViewById(R.id.result);
                        tv.setText("file has been created on SD card");
                } catch (Exception e) {
                        Log.e("Exception","error occurred while creating xml file");
                }
    }
}*/







/*




package org.anddev.android.webstuff;
 
import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
 
import org.apache.http.util.ByteArrayBuffer;
 
import android.app.Activity;
import android.app.NotificationManager;
import android.net.http.EventHandler;
import android.net.http.Headers;
import android.net.http.RequestQueue;
import android.net.http.SslCertificate;
import android.os.Bundle;
import android.util.Log;
 
public class HTTPPostExample extends Activity {
 
        // ===========================================================
        // Fields
        // ===========================================================
       
        private final String DEBUG_TAG = "httpPostExample";
 
        // ===========================================================
        // 'Constructors'
        // ===========================================================
 
        @Override
        public void onCreate(Bundle icicle) {
                super.onCreate(icicle);
 
                android.net.http.RequestQueue rQueue = new RequestQueue(this);
               
                String POSTText = null;
                try {
                        POSTText = "mydata=" + URLEncoder.encode("HELLO, ANDROID HTTPPostExample - by anddev.org", "UTF-8");
                } catch (UnsupportedEncodingException e) {
                        return;
                }
                byte[] POSTbytes = POSTText.getBytes();
                ByteArrayInputStream baos = new ByteArrayInputStream(POSTbytes);
               
                Map<String, String> headers = new HashMap<String, String>();
                headers.put("Content-Type", "application/x-www-form-urlencoded");
               
                MyEventHandler myEvH = new MyEventHandler(this);
 
             
                rQueue.queueRequest("http://www.anddev.org/postresponse.php", "POST",
                                headers, myEvH, baos, POSTbytes.length,false);
 
                rQueue.waitUntilComplete();
        }
       
        // ===========================================================
        // Worker Class
        // ===========================================================
       
        private class MyEventHandler implements EventHandler {
                private static final int RANDOM_ID = 0x1337;
 
                ByteArrayBuffer baf = new ByteArrayBuffer(20);
               
                private Activity myActivity;
 
                MyEventHandler(Activity activity) {
                        this.myActivity = activity;  }
 
                public void data(byte[] bytes, int len) {
                        baf.append(bytes, 0, len);  }
 
                public void endData() {
                        String text = new String(baf.toByteArray());
                        myShowNotificationAndLog("Data loaded: n" + text);  }
 
                public void status(int arg0, int arg1, int arg2, String s) {
                        myShowNotificationAndLog("status [" + s + "]");  }
 
                public void error(int i, String s) {
                        this.myShowNotificationAndLog("error [" + s + "]");  }
 
                public void handleSslErrorRequest(int arg0, String arg1, SslCertificate arg2) { }
                public void headers(Iterator arg0) { }
                public void headers(Headers arg0) { }
 
                private void myShowNotificationAndLog(String msg) {
                        Log.d(DEBUG_TAG, msg);
                        NotificationManager nm = (NotificationManager) this.myActivity
                                        .getSystemService(Activity.NOTIFICATION_SERVICE);
                        nm.notifyWithText(RANDOM_ID, msg, NotificationManager.LENGTH_LONG, null);
                }
        }
}
Parsed in 0.051 seconds, using GeSHi 1.0.8.4 
*/